Conversation
Greptile SummaryThis PR consolidates the Swoole adapters into two new classes (
Confidence Score: 1/5Not safe to merge — multiple P0 syntax/runtime errors will prevent the application from loading. Three independent P0 findings each independently block the application from running: a PHP parse error on the unnamed property, a syntax error in the compression conditional, and an undefined property reference. The PR is in an intermediate experiments state and should not be merged until these are resolved. src/Http/Http.php and src/Http/Response.php both have P0 errors that need immediate attention before this PR is mergeable. Important Files Changed
|
| * @var Hook[] | ||
| */ | ||
| protected static array $startHooks = []; | ||
| protected static array $ = []; |
There was a problem hiding this comment.
Syntax error: unnamed static property
protected static array $ = []; is not valid PHP — a property must have an identifier after $. PHP will throw a fatal parse error on this line, making the entire application unbootable. This appears to be the renamed $startHooks property (referenced on line 433 via self::$startHooks), whose name was lost during the refactor.
| if ( | ||
| !$hasContentEncoding | ||
| $this->compression | ||
| && !$hasContentEncoding | ||
| && !empty($this->acceptEncoding) | ||
| && $this->isCompressible($this->contentType) | ||
| && \strlen($body) > $this->compressionMinSize | ||
| && $this->compression->isCompressible(self); | ||
| ) { |
There was a problem hiding this comment.
Syntax error:
self keyword and stray semicolon in condition
self is a class-reference keyword in PHP, not an expression that can be passed as a method argument — this should be $this. Additionally, the trailing semicolon ; terminates the if condition early, making the && clause a separate (unreachable) statement. Both errors will cause a fatal parse/runtime error and prevent compression from ever being applied.
| if ( | |
| !$hasContentEncoding | |
| $this->compression | |
| && !$hasContentEncoding | |
| && !empty($this->acceptEncoding) | |
| && $this->isCompressible($this->contentType) | |
| && \strlen($body) > $this->compressionMinSize | |
| && $this->compression->isCompressible(self); | |
| ) { | |
| if ( | |
| $this->compression | |
| && !$hasContentEncoding | |
| && !empty($this->acceptEncoding) | |
| && $this->compression->isCompressible($this) | |
| ) { |
|
|
||
| $this->server->onStart(function ($server) { | ||
| $this->setResource('server', fn() => $server); | ||
| $this->resources->set('server', fn() => $server); |
There was a problem hiding this comment.
The constructor no longer assigns $this->container = $server->getContext() or declares a $resources property, yet this line calls $this->resources->set(...). The class still declares protected Container $container (line 43) but it is never initialized either. This will throw an "Undefined property" or "must not be accessed before initialization" fatal error at runtime when start() is called.
| public function isCompressible(Response $request): bool | ||
| { | ||
| $hasAcceptEncoding = !empty($request->getHeader('accept-encoding', '')); | ||
|
|
||
| $isCompressibleMimeType = isset($this->mimeTypes[$request->getHeader('content-type', '')]); | ||
| $isGreaterThanMinSize = \strlen($request->getRawPayload()) > $this->minSizeBytes; | ||
| return $isCompressibleMimeType && $isGreaterThanMinSize; | ||
| } |
There was a problem hiding this comment.
$hasAcceptEncoding computed but never used; misleading parameter name
The variable is calculated but excluded from the return expression, so the caller's Accept-Encoding presence is silently ignored by isCompressible. The parameter is also typed as Response but named $request, which is misleading.
| public function isCompressible(Response $request): bool | |
| { | |
| $hasAcceptEncoding = !empty($request->getHeader('accept-encoding', '')); | |
| $isCompressibleMimeType = isset($this->mimeTypes[$request->getHeader('content-type', '')]); | |
| $isGreaterThanMinSize = \strlen($request->getRawPayload()) > $this->minSizeBytes; | |
| return $isCompressibleMimeType && $isGreaterThanMinSize; | |
| } | |
| public function isCompressible(Response $response): bool | |
| { | |
| $isCompressibleMimeType = isset($this->mimeTypes[$response->getHeader('content-type', '')]); | |
| $isGreaterThanMinSize = \strlen($response->getRawPayload()) > $this->minSizeBytes; | |
| return $isCompressibleMimeType && $isGreaterThanMinSize; | |
| } |
No description provided.